package Ontology;

import dbcontext.FuncConstr;
import dbindex.Language;

public class WDFunc 
{

	private int iTermID;			//	Identifier of constraint
	private int iAttrOutID;			//	Identifier of attribute from domain ontology
	private int iRelationType;		//	Type of constraint 1 - hierarchy, 2 - associated, 0 - attribute belonging to class
	private int iRelationID;		//	ID from Class/Hier/Acon
	private int iFuncType;			//	0 - method, 1 - constant
	private int iFuncValue;			//	constant / class ID
	private int iSign;				//	0 = ; 1 > ; 2 <
	private int iIDFromDB;
	private int iConstrID;			//	Identifier of constraint (for internal use. In the current version is not used)
	private boolean bIsInherited;	//	Is inherited?
	private int iFatherClassID;		//	Class ID the relation is inherited from
	//	private int[] iArrDO;			// Array of attrs of the domain ontology
	//	private int[] iArrTMO;			// Array of attrs of the task&methods ontology
	
    //	public WDFunc( int iiTermID, int iiConstrID, int iiConstrType, boolean ibIsMethod, int iiArrLength, int[] iiArrDO,  int[] iiArrTMO, int iiIDFromDB )
    public WDFunc( int iiTermID, int iiAttrOutID, int iiRelationType, int iiRelationID, int iiFuncType, int iiFuncValue, int iiSign, int iiIDFromDB, int iiConstrID, boolean ibIsInherited, int iiFatherClassID  )
    {
    	iTermID = iiTermID;
    	iAttrOutID = iiAttrOutID;
    	iRelationType = iiRelationType;
    	iRelationID= iiRelationID;
    	iFuncType = iiFuncType;
    	iFuncValue = iiFuncValue;
    	iSign = iiSign;
    	iIDFromDB = iiIDFromDB;
    	iConstrID = iiConstrID;
    	//	iArrDO = new int[iiArrLength];
    	//	iArrTMO = new int[iiArrLength];
    	//	iArrDO = iiArrDO;
        //	iArrTMO = iiArrTMO;
    	bIsInherited = ibIsInherited;
    	iFatherClassID = iiFatherClassID;
    }
    
    public String toString() 
    {
        String s = "ConstraintID: " + iConstrID + " ConstraintType: " + iRelationType + 
        		"\n   IDFromBase: " + iIDFromDB + " IsIMethod: " + iFuncType; 
        		//	for (int i = 0; i < iArrDO.length; i++)  s = s + "\n   DOArray[" + i + "]: " + iArrDO[i] + " TMOArray[" + i + "]: " + iArrTMO[i];
        			
        return s;
    }
    public String toFileWithTab() 
    {
        return "" + iIDFromDB + "\t" 
        	+ iTermID + "\t"
                + iAttrOutID + "\t"
                + iRelationType + "\t"
                + iRelationID + "\t"
                + iFuncType + "\t"
                + iFuncValue;
    }
    /** Stores data to the table 'hierarchy' */
    public void toDatabase(java.sql.Connection webdeso_conn, java.sql.Connection context_conn, Language lang)
    {
        FuncConstr.insert(webdeso_conn, context_conn, lang, iTermID, iAttrOutID, 
                        iRelationType, iRelationID, iFuncType, iFuncValue, iSign);
    }
    
    public int getTermID() 
    {
        return iTermID;
    }
    public int getAttrOutID() 
    {
        return iAttrOutID;
    }
    public int getRelationType() 
    {
        return iRelationType;
    }
    public int getRelationID() 
    {
        return iRelationID;
    }
    public int getFuncType() 
    {
        return iFuncType;
    }
    public int getFuncValue() 
    {
        return iFuncValue;
    }
    public int getSign() 
    {
        return iSign;
    }
    public int getIDFromDB() 
    {
        return iIDFromDB;
    }
    public int getConstrID() 
    {
        return iConstrID;
    }
    public boolean getIsInherited() 
    {
        return bIsInherited;
    }
    public int getFatherClassID() 
    {
        return iFatherClassID;
    }

    public void setInheritedClassID( int iiFatherClassID ) 
    {
    	iFatherClassID = iiFatherClassID;
    	bIsInherited = true;
        return;
    }
    
    public void setIsNotInherited( ) 
    {
    	iFatherClassID = iRelationID;
    	bIsInherited = false;
        return;
    }

    /*
    public int[] getDOAttrs() 
    {
        return iArrDO;
    }
    
    public int[] getTMOAttrs() 
    {
        return iArrTMO;
    }
    */
}